<?php
namespace Mobile\Controller;
use Think\Controller;
class IndexController extends Controller {
	//手机首页
    public function index()
    {
    	//分类遍历
    	$cats = M('cat')->select();
    	$cats = gettree($cats);
    	$this->assign('cats',$cats);

    	//商品遍历
    	$g = I('get.g');
    	if ($g == 'new') {
    		$goods = M('goods')->where('is_new=1 and is_on_sale=1')->select();
    	}elseif ($g == 'hot') {
    		$goods = M('goods')->where('is_hot=1 and is_on_sale=1')->select();
    	}else {
    		$goods = M('goods')->where('is_on_sale=1')->select();
    	}
    	$this->assign('goods',$goods);

    	//数量
    	$new_num = M('goods')->where('is_new=1 and is_on_sale=1')->count();
    	$this->assign('new_num',$new_num);

    	$hot_num = M('goods')->where('is_hot=1 and is_on_sale=1')->count();
    	$this->assign('hot_num',$hot_num);

    	$num = M('goods')->where('is_on_sale=1')->count();
    	$this->assign('num',$num);

        $this->display();
    }
}